/**
 * @author LKQ
 * @date 2022/2/26 10:05
 * @description 计数排序，n <= 10000， 9999加起来最大为36;
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int countLargestGroup(int n) {
        int[] arr = new int[40];
        for(int i = 1; i <= n; i++) {
            int cnt = 0, start = i;
            while(start != 0) {
                cnt += start % 10;
                start /= 10;
            }
            arr[cnt]++;
        }
        int max = 0;
        for(int i = 0; i < 40; i++) {
            max = Math.max(arr[i], max);
        }
        int ans = 0;
        for(int i = 0; i < 40; i++) {
            if(arr[i] == max) {
                ans++;
            }
        }
        return ans;
    }
}
